package xin.lhuo.we.server.utils;

import xin.lhuo.we.server.vo.ResultVo;
import xin.lhuo.we.server.enums.ResultEnum;

/**
 * @author Lhuo
 * @date 2019/5/5 11:20
 */
public class ResultVoUtil {
    public static ResultVo success(Object obj) {
        ResultVo resultVO = new ResultVo();
        resultVO.setCode(ResultEnum.SUCCESS.getCode());
        resultVO.setMsg(ResultEnum.SUCCESS.getMsg());
        resultVO.setData(obj);
        return resultVO;
    }

    public static ResultVo success() {
        return success(null);
    }

    public static ResultVo error(ResultEnum resultEnum) {
        ResultVo resultVO = new ResultVo();
        resultVO.setCode(resultEnum.getCode());
        resultVO.setMsg(resultEnum.getMsg());
        return resultVO;
    }

    public static ResultVo error(Integer code, String msg) {
        ResultVo resultVO = new ResultVo();
        resultVO.setCode(code);
        resultVO.setMsg(msg);
        return resultVO;
    }

}
